package com.bckj.fastboot.upms.api.service;

import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.upms.api.constant.UpmsConstant;
import com.bckj.fastboot.upms.api.dto.SysDictQuery;
import com.bckj.fastboot.upms.api.dto.SysDictRequest;
import com.bckj.fastboot.upms.api.entity.SysDict;
import com.bckj.fastboot.upms.api.vo.SysDictVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = UpmsConstant.SERVICE_ID, contextId = "sysDict", path = "sysDict")
public interface SysDictRemoteService {

    /**
     * 分页
     */
    @GetMapping("page")
    PageResult<SysDictVO> page(@SpringQueryMap SysDictQuery query);

    /**
     * 增加
     */
    @PostMapping("save")
    boolean save(@RequestBody @Validated SysDictRequest request);

    /**
     * 更新
     */
    @PutMapping("update")
    boolean update(@RequestBody @Validated SysDictRequest request);

    /**
     * 获取明细
     */
    @GetMapping("/{id}")
    SysDictVO details(@PathVariable Long id);

    /**
     * 启用/禁用
     */
    @PutMapping("/{id}/enabled")
    boolean enabled(@PathVariable Long id);

    /**
     * 移除
     *
     * @param id id
     * @return boolean
     */
    @DeleteMapping("{id}")
    boolean remove(@PathVariable Long id);


    /**
     * 根据类型获取字典（Cache）
     * @param type 字典类型
     * @return {@link List}<{@link SysDict}>
     */
    @GetMapping("listByType")
    List<SysDict> listByType(@RequestParam("type") String type);
}
